home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
apidev
/
mhs_c.arc
/
OUTPOST.ARC
/
OUTFILE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-06-27
|
2KB
|
107 lines
/* ******************************* OUTFILE.C ****************************** */
#include "cctypes.h"
extern int OutFile;
extern int InFile;
extern char OutExtension[];
extern int ErrorsInThisFile;
extern int WarningsInThisFile;
extern char InFileName[];
extern char OutFileName[];
extern long fileSize;
extern int contentsWritten;
extern char messageBuffer[];
extern FILEINFO fileInfo;
extern char *XRBRec[];
void BlankLine();
void WriteIt();
int SetUpOutFile()
{
int ccode;
/* open the output file */
ccode = OpenOutputFile(OutExtension);
if ( ccode)
return(CANNOT_CREATE_OUTPUT);
WriteIt("Message:");
BlankLine();
return(0);
}
void BlankLine()
{
write(OutFile, "\15\12", 2); /* CR-LF */
}
void WriteIt(string)
char *string;
{
write(OutFile, string, strlen(string));
}
int WriteCCMFileMsg() /* saved for last */
{
char ch[3];
int bytes = 0, returnCode = 0, temp, ccode;
long fPtr = 0L;
/* first, close the .XRB file */
close(InFile);
if ( !contentsWritten ) {
contentsWritten++;
WriteIt("Contents:");
BlankLine();
}
/* get the message from the SMF file */
sprintf(InFileName, "Q:OUT\\%s", fileInfo.fileName);
ccode = OpenInputFile();
if ( ccode ) {
Error(CANNOT_OPEN_FILE);
goto Out;
}
/* determine where the message begins */
/* it begins where the message header ends - <LF><LF> or <LF><CR><LF> */
fPtr = lseek(InFile, 128L, 0);
while (1) {
if ( read(InFile, ch, 1) == 0 ) goto NoMessage;
if ( ch[0] == (char)10 ) {
if ( read(InFile, ch, 1) == 0 ) goto NoMessage;
if ( ch[0] == (char)13 )
if ( read(InFile, ch, 1) == 0 ) goto NoMessage;
if ( ch[0] == (char)10 )
break;
}
}
temp = strlen(messageBuffer);
bytes = read(InFile, &messageBuffer[temp - 1],
MESSAGE_SIZE - temp);
messageBuffer[temp+bytes-1] = '\0';
WriteIt("Text item:");
BlankLine();
NoMessage:
if ( strlen(messageBuffer) )
WriteIt(messageBuffer);
fileSize = lseek(OutFile,(long)0,2);
close(OutFile); /* close the .CCM file */
close(InFile); /* close the SMF file */
if ( fileSize == 0L )
returnCode = -1;
Out:
return(returnCode);
}